package com.aspose.cells;

class zavz {
   static double a(byte[] var0, int var1) {
      return a(com.aspose.cells.b.a.zc.a(var0, var1));
   }

   static double a(int var0) {
      switch(var0 & 3) {
      case 1:
         return Double.longBitsToDouble(((long)var0 & 4294967292L) << 32) / 100.0D;
      case 2:
         return (double)(var0 >> 2);
      case 3:
         return (double)(var0 >> 2) / 100.0D;
      default:
         return Double.longBitsToDouble((long)var0 << 32);
      }
   }

   static String b(int var0) {
      String var1;
      switch(var0 & 3) {
      case 1:
         var1 = com.aspose.cells.a.c.zp.b(Double.longBitsToDouble(((long)var0 & 4294967292L) << 32));
         int var2 = var1.indexOf(46);
         if (var2 < 0) {
            return a(var1);
         } else {
            if (var2 == 1) {
               if (var1.charAt(0) == '-') {
                  return "-0.00" + var1.substring(2);
               }

               return "0.0" + var1.charAt(0) + var1.substring(2);
            }

            return a(var1.substring(0, 0 + var2)) + var1.substring(var2 + 1);
         }
      case 2:
         return com.aspose.cells.b.a.zo.a(var0 >> 2);
      case 3:
         var1 = com.aspose.cells.b.a.zo.a(var0 >> 2);
         return a(var1);
      default:
         return com.aspose.cells.a.c.zp.b(Double.longBitsToDouble((long)var0 << 32));
      }
   }

   private static String a(String var0) {
      switch(var0.length()) {
      case 0:
         return "0.00";
      case 1:
         return var0.charAt(0) == '0' ? "0" : "0.0" + var0;
      case 2:
         if (var0.charAt(0) == '-') {
            return "-0.0" + var0.charAt(1);
         }

         return "0." + var0;
      case 3:
         if (var0.charAt(0) == '-') {
            return "-0." + var0.substring(1);
         }

         return var0.charAt(0) + "." + var0.substring(1);
      default:
         int var1 = var0.length() - 2;
         return var0.substring(0, 0 + var1) + "." + var0.substring(var1, var1 + 2);
      }
   }

   static void a(long var0, zfv var2) {
      if (var0 <= 536870911L && var0 >= -536870912L) {
         var2.c = 6;
         var2.d = (int)var0 << 2 | 2;
      } else {
         long var3 = Double.doubleToRawLongBits((double)var0);
         if ((var3 & 17179869183L) == 0L) {
            var2.c = 6;
            var2.d = (int)(var3 >> 32);
         } else {
            var3 = Double.doubleToRawLongBits((double)var0 * 100.0D);
            if ((var3 & 17179869183L) == 0L) {
               var2.c = 6;
               var2.d = (int)(var3 >> 32) | 1;
            } else {
               var2.c = 1;
               var2.d = (double)var0;
            }
         }
      }
   }

   static void a(double var0, zfv var2) {
      if (var0 != 5.36870911E8D && var0 != -5.36870912E8D) {
         if (var0 < 5.36870911E8D && var0 > -5.36870912E8D) {
            int var3 = (int)var0;
            if (Math.abs(var0 - (double)var3) < Double.MIN_VALUE) {
               var3 <<= 2;
               var3 |= 2;
               var2.c = 6;
               var2.d = var3;
               return;
            }
         }

         long var10 = Double.doubleToRawLongBits(var0);
         if ((var10 & 17179869183L) == 0L) {
            var2.c = 6;
            var2.d = (int)(var10 >> 32);
         } else {
            if (var0 <= 1.7976931348623156E306D && var0 >= -1.7976931348623156E306D) {
               String var5 = com.aspose.cells.a.c.zp.b(var0);
               int var6 = var5.indexOf(69) + 1;
               if (var6 > 0) {
                  var5 = var5.substring(0, 0 + var6) + (com.aspose.cells.b.a.zo.a(var5.substring(var6), com.aspose.cells.b.a.c.za.b()) + 2);
               } else {
                  var6 = var5.indexOf(46);
                  if (var6 < 0) {
                     var5 = var5 + "00";
                  } else {
                     switch(var5.length() - var6) {
                     case 1:
                        var5 = var5.substring(0, 0 + var6) + "00";
                        break;
                     case 2:
                        var5 = var5.substring(0, 0 + var6) + var5.charAt(var6 + 1) + "0";
                        break;
                     case 3:
                        var5 = var5.substring(0, 0 + var6) + var5.substring(var6 + 1);
                        break;
                     default:
                        var5 = var5.substring(0, 0 + var6) + var5.substring(var6 + 1, var6 + 1 + 2) + "." + var5.substring(var6 + 3);
                     }
                  }
               }

               double var7 = com.aspose.cells.b.a.zn.a(var5, com.aspose.cells.b.a.c.za.b());
               if (var7 == 5.36870911E8D || var7 == -5.36870912E8D) {
                  var2.c = 6;
                  var2.d = (int)var7 << 2 | 3;
                  return;
               }

               if (var7 < 5.36870911E8D && var7 > -5.36870912E8D) {
                  int var9 = (int)var7;
                  if (Math.abs(var7 - (double)var9) < Double.MIN_VALUE) {
                     var9 <<= 2;
                     var9 |= 3;
                     var2.c = 6;
                     var2.d = var9;
                     return;
                  }
               }

               var10 = Double.doubleToRawLongBits(var7);
               if ((var10 & 17179869183L) == 0L) {
                  var2.c = 6;
                  var2.d = (int)(var10 >> 32) | 1;
                  return;
               }
            }

            var2.c = 1;
            var2.d = var0;
         }
      } else {
         var2.c = 6;
         var2.d = (int)var0 << 2 | 2;
      }
   }

   static void a(String var0, String var1, zfv var2) {
      if (var1.length() < 3) {
         b(var1.length() == 1 ? var0 + var1 + "0" : var0 + var1, var2);
      } else {
         double var3 = com.aspose.cells.b.a.zn.a(var0 + "." + var1, com.aspose.cells.b.a.c.za.b());
         long var5 = Double.doubleToRawLongBits(var3);
         if ((var5 & 17179869183L) == 0L) {
            var2.c = 6;
            var2.d = (int)(var5 >> 32);
         } else {
            if (var1.length() > 2) {
               double var7 = com.aspose.cells.b.a.zn.a(var0 + var1.substring(0, 2) + "." + var1.substring(2), com.aspose.cells.b.a.c.za.b());
               var5 = Double.doubleToRawLongBits(var7);
               if ((var5 & 17179869183L) == 0L) {
                  var2.c = 6;
                  var2.d = (int)(var5 >> 32) | 1;
                  return;
               }
            }

            var2.c = 1;
            var2.d = var3;
         }
      }
   }

   static void a(String var0, zfv var1) {
      int var2 = var0.indexOf(69);
      if (var2 < 0) {
         var2 = var0.indexOf(101);
      }

      int var3;
      if (var2 < 0) {
         var2 = var0.indexOf(46);
         if (var2 < 0) {
            c(var0, var1);
         } else {
            for(var3 = var0.length() - 1; var3 > var2; --var3) {
               if (var0.charAt(var3) != '0') {
                  a(var0.substring(0, 0 + var2), var0.substring(var2 + 1, var2 + 1 + (var3 - var2)), var1);
                  return;
               }
            }

            c(var0.substring(0, 0 + var2), var1);
         }
      } else {
         var3 = com.aspose.cells.b.a.zo.a(var0.charAt(var2 + 1) == '+' ? var0.substring(var2 + 2) : var0.substring(var2 + 1), com.aspose.cells.b.a.c.za.b());
         int var4;
         if (var3 == 0) {
            var4 = var0.indexOf(46);
            if (var4 > -1 && var4 < var2) {
               --var2;

               while(var2 > var4) {
                  if (var0.charAt(var2) != '0') {
                     a(var0.substring(0, 0 + var4), var0.substring(var4 + 1, var4 + 1 + (var2 - var4)), var1);
                     return;
                  }

                  --var2;
               }
            }

            c(var0.substring(0, 0 + var2), var1);
         } else {
            if (var3 < 0) {
               if (var3 > -20) {
                  var4 = var0.indexOf(46);
                  if (var4 > -1 && var4 < var2) {
                     --var2;

                     while(var2 > var4) {
                        if (var0.charAt(var2) != '0') {
                           if (var0.charAt(0) == '-') {
                              if (var4 > 1 - var3) {
                                 a(var0.substring(0, 0 + var4 + var3), var0.substring(var4 + var3, var4 + var3 + -var3) + var0.substring(var4 + 1, var4 + 1 + (var2 - var4)), var1);
                              } else if (var4 == 1 - var3) {
                                 a("-0", var0.substring(1, 1 + (var4 - 1)) + var0.substring(var4 + 1, var4 + 1 + (var2 - var4)), var1);
                              } else {
                                 a("-0", com.aspose.cells.b.a.zv.a('0', 1 - var3 - var4) + var0.substring(1, 1 + (var4 - 1)) + var0.substring(var4 + 1, var4 + 1 + (var2 - var4)), var1);
                              }
                           } else if (var4 > -var3) {
                              a(var0.substring(0, 0 + var4 + var3), var0.substring(var4 + var3, var4 + var3 + -var3) + var0.substring(var4 + 1, var4 + 1 + (var2 - var4)), var1);
                           } else if (var4 == -var3) {
                              a("0", var0.substring(0, 0 + var4) + var0.substring(var4 + 1, var4 + 1 + (var2 - var4)), var1);
                           } else {
                              a("0", com.aspose.cells.b.a.zv.a('0', -var3 - var4) + var0.substring(0, 0 + var4) + var0.substring(var4 + 1, var4 + 1 + (var2 - var4)), var1);
                           }

                           return;
                        }

                        --var2;
                     }
                  }

                  --var2;
                  if (var0.charAt(0) == '-') {
                     while(var2 > 0) {
                        if (var0.charAt(var2) != '0') {
                           ++var2;
                           if (var2 > 1 - var3) {
                              a(var0.substring(0, 0 + var2 + var3), var0.substring(var2 + var3, var2 + var3 + -var3), var1);
                           } else if (var2 == 1 - var3) {
                              a("-0", var0.substring(1, 1 + (var2 - 1)), var1);
                           } else {
                              a("-0", com.aspose.cells.b.a.zv.a('0', 1 - var3 - var2) + var0.substring(1, 1 + (var2 - 1)), var1);
                           }

                           return;
                        }

                        ++var3;
                        if (var3 == 0) {
                           c(var0.substring(0, 0 + var2), var1);
                           return;
                        }

                        --var2;
                     }
                  } else {
                     while(var2 > -1) {
                        if (var0.charAt(var2) != '0') {
                           ++var2;
                           if (var2 > -var3) {
                              a(var0.substring(0, 0 + var2 + var3), var0.substring(var2 + var3, var2 + var3 + -var3), var1);
                           } else if (var2 == -var3) {
                              a("0", var0.substring(0, 0 + var2), var1);
                           } else {
                              a("0", com.aspose.cells.b.a.zv.a('0', -var3 - var2) + var0.substring(0, 0 + var2), var1);
                           }

                           return;
                        }

                        ++var3;
                        if (var3 == 0) {
                           c(var0.substring(0, 0 + var2), var1);
                           return;
                        }

                        --var2;
                     }
                  }

                  var1.c = 6;
                  var1.d = 2;
                  return;
               }
            } else if (var3 < 20) {
               var4 = var0.indexOf(46);
               if (var4 >= 0 && var4 <= var2) {
                  int var5 = var2 - var4 - 1;
                  if (var3 > var5) {
                     c(var0.substring(0, 0 + var4) + var0.substring(var4 + 1, var4 + 1 + var5) + com.aspose.cells.b.a.zv.a('0', var3 - var5), var1);
                  } else if (var3 == var5) {
                     c(var0.substring(0, 0 + var4) + var0.substring(var4 + 1, var4 + 1 + var5), var1);
                  } else {
                     a(var0.substring(0, 0 + var4) + var0.substring(var4 + 1, var4 + 1 + var3), var0.substring(var4 + 1 + var3, var4 + 1 + var3 + (var5 - var3)), var1);
                  }

                  return;
               }

               c(var0.substring(0, 0 + var2) + com.aspose.cells.b.a.zv.a('0', var3), var1);
               return;
            }

            double var10 = com.aspose.cells.b.a.zn.a(var0, com.aspose.cells.b.a.c.za.b());
            long var6 = Double.doubleToRawLongBits(var10);
            if ((var6 & 17179869183L) == 0L) {
               var1.c = 6;
               var1.d = (int)(var6 >> 32);
            } else {
               if (var3 < 306) {
                  double var8 = com.aspose.cells.b.a.zn.a(var0.substring(0, 0 + var2) + "E" + (var3 + 2), com.aspose.cells.b.a.c.za.b());
                  var6 = Double.doubleToRawLongBits(var10);
                  if ((var6 & 17179869183L) == 0L) {
                     var1.c = 6;
                     var1.d = (int)(var6 >> 32) | 1;
                     return;
                  }
               }

               var1.c = 1;
               var1.d = var10;
            }
         }
      }
   }

   private static void b(String var0, zfv var1) {
      long var2;
      if (b(var0)) {
         var2 = com.aspose.cells.b.a.zp.a(var0, com.aspose.cells.b.a.c.za.b());
         if (var2 <= 536870911L && var2 >= -536870912L) {
            var1.c = 6;
            var1.d = (int)var2 << 2 | 3;
            return;
         }

         var2 = Double.doubleToRawLongBits((double)var2);
      } else {
         var2 = Double.doubleToRawLongBits(com.aspose.cells.b.a.zn.a(var0, com.aspose.cells.b.a.c.za.b()));
      }

      if ((var2 & 17179869183L) == 0L) {
         var1.c = 6;
         var1.d = (int)(var2 >> 32) | 1;
      } else {
         double var4 = com.aspose.cells.b.a.zn.a(var0.substring(0, 0 + (var0.length() - 2)) + "." + var0.substring(var0.length() - 2), com.aspose.cells.b.a.c.za.b());
         var2 = Double.doubleToRawLongBits(var4);
         if ((var2 & 17179869183L) == 0L) {
            var1.c = 6;
            var1.d = (int)(var2 >> 32);
         } else {
            var1.c = 1;
            var1.d = var4;
         }
      }
   }

   private static void c(String var0, zfv var1) {
      if (b(var0)) {
         a(com.aspose.cells.b.a.zp.a(var0, com.aspose.cells.b.a.c.za.b()), var1);
      } else {
         double var2 = com.aspose.cells.b.a.zn.a(var0, com.aspose.cells.b.a.c.za.b());
         long var4 = Double.doubleToRawLongBits(var2);
         if ((var4 & 17179869183L) == 0L) {
            var1.c = 6;
            var1.d = (int)(var4 >> 32);
         } else {
            var4 = Double.doubleToRawLongBits(com.aspose.cells.b.a.zn.a(var0 + "00", com.aspose.cells.b.a.c.za.b()));
            if ((var4 & 17179869183L) == 0L) {
               var1.c = 6;
               var1.d = (int)(var4 >> 32) | 1;
            } else {
               var1.c = 1;
               var1.d = var2;
            }
         }
      }
   }

   private static boolean b(String var0) {
      if (var0.length() < 19) {
         return true;
      } else {
         int var1 = 0;
         if (var0.charAt(0) == '-') {
            var1 = 1;
         }

         while(var1 < var0.length()) {
            switch(var0.charAt(var1)) {
            case '0':
               ++var1;
               break;
            case '9':
               return var0.length() - var1 < 19;
            default:
               return var0.length() - var1 < 20;
            }
         }

         return true;
      }
   }
}
